using System;
using System.Collections.Generic;
using System.Text;

namespace Common
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public struct SchemaObject : IComparable
    {
        /// <summary></summary>
        public DataProviderType Provider;
        /// <summary></summary>
        public string DataSource;
        /// <summary></summary>
        public string CatalogName;
        /// <summary></summary>
        public string Schema;
        /// <summary></summary>
        public string TableName;
        /// <summary></summary>
        public string SelectCommand;
        /// <summary></summary>
        public string UserID;
        /// <summary></summary>
        public string Password;
        /// <summary></summary>
        public DBAuthenticationType AuthType;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string thisName = (string.IsNullOrEmpty(this.CatalogName) ? string.Empty : this.CatalogName);
            thisName += "." + (string.IsNullOrEmpty(this.Schema) ? string.Empty : this.Schema);
            thisName += "." + (string.IsNullOrEmpty(this.TableName) ? string.Empty : this.TableName);
            return thisName;
        }

        #region IComparable Members

        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            if (obj.GetType() == typeof(SchemaObject))
            {
                return this.ToString().CompareTo(obj.ToString());
            }
            else
            {
                return 0;
            }
        }

        #endregion
    }
}
